/* 商品管理详情 */
<template>
  <div class="app-container">
    <div style="padding:20px;min-height:740px">
        <div style="margin-bottom:16px">
            <span style="display:inline-block; background-color: #1890FF;margin-bottom: -2px; margin-right: 8px; width: 3px; height: 14px"></span>
            <span class="top_title">商品详情</span>
        </div>
        <el-descriptions class="margin-top" :column="3" border>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="商品编码">{{commodityDetail.code}}</el-descriptions-item>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="商品名称">{{commodityDetail.name}}</el-descriptions-item>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="ERP商品名称">{{commodityDetail.erpName}}</el-descriptions-item>
            <el-descriptions-item label="副名称">{{commodityDetail.subName}}</el-descriptions-item>
            <el-descriptions-item label="商品型号">{{commodityDetail.model}}</el-descriptions-item>
            <el-descriptions-item label="规格代号">{{commodityDetail.specifications}}</el-descriptions-item>
            <el-descriptions-item label="默认单位">{{commodityDetail.defaultUnitName}}</el-descriptions-item>
            <el-descriptions-item label="适应环境温度">{{commodityDetail.temperature}}</el-descriptions-item>
            <el-descriptions-item label="参图号">{{commodityDetail.referencedNumber}}</el-descriptions-item>
            <el-descriptions-item label="目标重量">{{commodityDetail.targetWeight}}</el-descriptions-item>
            <el-descriptions-item label="使用状态">{{commodityDetail.erpStatus == '00'?'可用':commodityDetail.erpStatus == '01'?'禁用':'反审核中'}}</el-descriptions-item>
            <el-descriptions-item label="是否是套包">{{commodityDetail.groupGoods?'是':'否'}}</el-descriptions-item>
            <el-descriptions-item label="" v-if="commodityDetail.remark && commodityDetail.releaseNotes.length > 42"></el-descriptions-item>
            <el-descriptions-item label="" v-if="commodityDetail.remark && commodityDetail.releaseNotes.length > 42"></el-descriptions-item>
            <el-descriptions-item label="商品类型">{{commodityDetail.attribute == '010'?'物资':commodityDetail.attribute == '020'?'服务':''}}</el-descriptions-item>
            <el-descriptions-item label="辅助单位">{{commodityDetail.auxiliaryUnitName}}</el-descriptions-item>
            <el-descriptions-item label="辅助单位数量">{{commodityDetail.transferStandard}}</el-descriptions-item>
            <el-descriptions-item :span="3" label="设计备注">{{commodityDetail.releaseNotes}}</el-descriptions-item>

            <!-- <el-descriptions-item label=""></el-descriptions-item> -->
        </el-descriptions>
        <div style="width:100%;height:20px"></div>
        <el-descriptions class="margin-top" :column="3" border>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="商品分类">{{commodityDetail.goodsClassName}}</el-descriptions-item>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="商品类别">{{commodityDetail.categoryName}}</el-descriptions-item>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="品牌">{{commodityDetail.brandName}}</el-descriptions-item>
            <el-descriptions-item label="订货分类">{{commodityDetail.orderClassName}}</el-descriptions-item>
            <el-descriptions-item label="最小发货数量">{{commodityDetail.minPackage}}</el-descriptions-item>
            <el-descriptions-item label="最低起运量">{{commodityDetail.minQuantity}}</el-descriptions-item>
            <el-descriptions-item label="上架状态">{{commodityDetail.statusName}}</el-descriptions-item>
            <el-descriptions-item label="" v-if="commodityDetail.remark && commodityDetail.remark.length > 42"></el-descriptions-item>
            <el-descriptions-item label="" v-if="commodityDetail.remark && commodityDetail.remark.length > 42"></el-descriptions-item>
            <el-descriptions-item label="备注">{{commodityDetail.remark}}</el-descriptions-item>
        </el-descriptions>
        <template v-if="commodityDetail.groupGoods">
          <div style="margin-bottom:16px;margin-top: 20px;">
              <span style="display:inline-block; background-color: #1890FF;margin-bottom: -2px; margin-right: 8px; width: 3px; height: 14px"></span>
              <span style="display: inline-block;font-weight: 500;color: #333333;font-size: 16px;">套包明细</span>
          </div>
          <div>
            <el-table
              :data="commodityDetail.groupDetailList ? commodityDetail.groupDetailList : []" 
              ref="filterTable"
              :row-style="{height:'47px'}"
              border
            >
              <el-table-column label="序号" align="center" type="index" width="60"/>
              <el-table-column label="商品编码" align="center" prop="code" min-width="180"></el-table-column>
              <el-table-column label="商品名称" align="center" prop="name" min-width="180" show-overflow-tooltip></el-table-column>
              <el-table-column label="数量" align="center" prop="amount" min-width="120" show-overflow-tooltip></el-table-column>
              <el-table-column label="商品类别" align="center" prop="category" min-width="160" show-overflow-tooltip :formatter="row => getGoodsType(row.category)"></el-table-column>
              <el-table-column label="商品分类" align="center" prop="goodsClassName" min-width="160" show-overflow-tooltip></el-table-column>
              <el-table-column label="品牌" align="center" prop="brand" min-width="140"  :formatter="row => getBrandType(row.brand)"></el-table-column>
              <el-table-column label="上架状态" align="center" prop="status" min-width="140" :formatter="row => getStatusType(row.status)"></el-table-column>
              <el-table-column label="参图号" align="center" prop="referencedNumber" min-width="140"></el-table-column>
              <el-table-column label="设计备注" align="center" prop="releaseNotes" min-width="140"></el-table-column>
            </el-table>
          </div>
        </template>
    </div>
    <div class="h84_line"></div>
    <div class="bottom-btn">
        <div class="bottom-locate" >
          <el-button type="default" @click="cancel">返回</el-button>
        </div>
      </div>
  </div>
</template>

<script>
import QueryTableRender from "@/components/QueryTableRender";
import { getGoods } from "@/api/basic/commodity";
// import {getOrderTerminalList} from "@/api/costManagement";
// import DialogCostEdit from "@/views/costManagement/components/DialogCostEdit";
// import dayjs from "dayjs"
import { getToken } from "@/utils/auth";

export default {
  name: "CommodityManageDetail",
  dicts: ['sys_normal_disable', 'sys_user_sex','basic_data_goods_type','basic_data_goods_brand','basic_data_goods_status','basic_data_customer_erp_status'],
  components: {QueryTableRender},
  data() {
    return {
      form: {},
      queryModel:{},
      rules:{},
      deptOptions: [],
      editVisible: false,
      curRecord: null,
      customerValue: [], //  价目数据
      customerData: [],
      loading:false,
      height:200,
      contractList:[],
      dialogImageUrl: '',
      dialogVisible: false,
      imageList:[], //上传图片
      commodityDetail:{},//详情获取
    }
  },
  created() {
    this.getCommodityDetail();
  },
  watch: {
    $route() {
        // location.reload();
        this.getCommodityDetail();
    },
  },
  methods: {
    /**
     * @param {*} value 
     */
     getGoodsType(value) {
      let show = '';
      this.dict.type.basic_data_goods_type.some((item) => {
        if (value == item.value) {
          show = item.label;
          return true;
        }
      });
      return show;
    },
    getBrandType(value){
      let show = '';
      this.dict.type.basic_data_goods_brand.some((item) => {
        if (value == item.value) {
          show = item.label;
          return true;
        }
      });
      return show;
    },
    getStatusType(value){
      let show = '';
      this.dict.type.basic_data_goods_status.some((item) => {
        if (value == item.value) {
          show = item.label;
          return true;
        }
      });
      return show;
    },
    /** 获取商品详情 */
    getCommodityDetail() {
        // console.log(this.$route.query.goodsId)
        if(this.$route.query.goodsId){
            const str = {
                goodsId:JSON.parse(this.$route.query.goodsId)
            }
            getGoods(str).then(response => {
                this.commodityDetail = response.data;
                // this.commodityDetail.releaseNotes = '公园的工作人员小玉介绍，前一阵子，公司资金链一度较为紧张，多亏了国家的税费度较为紧张，多亏了国家的税费';
                // this.commodityDetail.remark = '公园的工作人员小玉介绍，前一阵子，公司资金链一度较为紧张，多亏了国家的税费度较为紧张，多亏了国家的税费';
                this.form = response.data;
                console.log(this.form)
            });
        }
    },
    /** 取消 */
    cancel() {
    //   this.$router.go(-1)
      const obj = { path: "/basicData/commodityManage" };
      this.$tab.closeOpenPage(obj);
    },
  }
}
</script>

<style lang="scss" scoped>
.top_title {
    display: inline-block; 
    font-weight: 500; 
    color: #333333; 
    font-size: 16px;
    font-family: PingFangSC-Medium;
}
::v-deep .hasTagsView .app-main {
    overflow: auto !important;
}
</style>